package com.situ.week1.homework;

import org.junit.Test;

import java.util.Scanner;

public class Work3 {

    public static String trim(String str) {
        char[] array = str.toCharArray();
        int start = 0;
        int end = array.length - 1;
        for (int i = 0; i < array.length; i++) {
            if (array[i] != '-') {
                start = i;
                break;
            }
        }
        for (int j = end; j >=0; j--) {
            if (array[j] != '-') {
                end = j;
                break;
            }
        }
        String newStr = str.substring(start, end+1);
        return newStr;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String str = scanner.nextLine();
        String newStr = trim(str);
        System.out.println(newStr);
    }
    @Test
    public void test2() {
        String str="I Love Java！";
        System.out.println(str.toLowerCase());
    }

}
